static FILE *file_in;
static FILE *file_out;
+#define MYNAME "CSV"
+
static void
rd_init(const char *fname)
{
file_in = fopen(fname, "r");
if (file_in == NULL) {
- fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+ fatal(MYNAME ": Cannot open %s for reading\n", fname);
}
}
{
file_out = fopen(fname, "w");
if (file_out == NULL) {
- fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+ fatal(MYNAME ": Cannot open %s for writing\n", fname);
}
}
&lat, &lon, desc) > 0) {
wpt_tmp = calloc(sizeof(*wpt_tmp),1);
if (wpt_tmp == NULL) {
- fatal("GPSMAN: cannot allocate memory\n");
+ fatal(MYNAME ": cannot allocate memory\n");
}
while (*odesc == ' ' || *odesc == '\t') {
odesc++;
static FILE *in_file;
static FILE *out_file;
+#define MYNAME "GPSMAN"
+
static void
gpsman_rd_init(const char *fname)
{
in_file = fopen(fname, "r");
if (in_file == NULL) {
- fatal("GPSMAN: Cannot open %s for reading\n", fname);
+ fatal(MYNAME ": Cannot open %s for reading\n", fname);
}
}
{
out_file = fopen(fname, "w");
if (out_file == NULL) {
- fatal("GPSMAN: Cannot open %s for writing\n", fname);
+ fatal(MYNAME ": Cannot open %s for writing\n", fname);
}
fprintf(out_file, "!Format: DDD 1 WGS 84\n");
wpt_tmp = calloc(sizeof(*wpt_tmp),1);
if (wpt_tmp == NULL) {
- fatal("GPSMAN: Cannot allocate enough memory\n");
+ fatal(MYNAME ": Cannot allocate enough memory\n");
}
lat = latm + latf;
static FILE *file_in;
static FILE *file_out;
+#define MYNAME "GPSUTIL"
+
static void
rd_init(const char *fname)
{
file_in = fopen(fname, "r");
if (file_in == NULL) {
- fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+ fatal(MYNAME ": Cannot open %s for reading\n", fname);
}
}
{
file_out = fopen(fname, "w");
if (file_out == NULL) {
- fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+ fatal(MYNAME ": Cannot open %s for writing\n", fname);
}
}
&alt, &alttype, desc, icon) > 0) {
wpt_tmp = calloc(sizeof(*wpt_tmp),1);
if (wpt_tmp == NULL) {
- fatal("GPSMAN: cannot allocate memory\n");
+ fatal(MYNAME ": cannot allocate memory\n");
}
wpt_tmp->position.altitude.altitude_meters = alt;
wpt_tmp->shortname = strdup(name);
static FILE *fd;
static FILE *ofd;
+#define MYNAME "GPX"
+
static void
tag_gpx(const char **attrv)
{
wpt_tmp = calloc(sizeof(*wpt_tmp), 1);
if (wpt_tmp == NULL) {
- fatal("Can not allocate memory\n");
+ fatal(MYNAME ": allocate memory\n");
}
while (*avp) {
{
fd = fopen(fname, "r");
if (fd == NULL) {
- fatal("GPX: Cannot open %s for reading\n", fname );
+ fatal(MYNAME ": Cannot open %s for reading\n", fname );
}
psr = XML_ParserCreate(NULL);
if (!psr) {
- fatal("GPX: Cannot create XML Parser\n");
+ fatal(MYNAME ": Cannot create XML Parser\n");
}
XML_SetElementHandler(psr, gpx_start, gpx_end);
XML_SetCharacterDataHandler(psr, gpx_cdata);
{
ofd = fopen(fname, "w");
if (ofd == NULL) {
- fatal("GPX: Cannot open %s for writing\n", fname );
+ fatal(MYNAME ": open %s for writing\n", fname );
}
}
len = fread(buf, 1, sizeof(buf), fd);
done = feof(fd);
if (!XML_Parse(psr, buf, len, done)) {
- fatal("GPX: XML parse error at %d: %s\n",
+ fatal(MYNAME ": XML parse error at %d: %s\n",
XML_GetCurrentLineNumber(psr),
XML_ErrorString(XML_GetErrorCode(psr)));
}
#include "magellan.h"
#define BAUDRATE B4800
+#define MYNAME "MAGPROTO"
#if __WIN32__
#include <windows.h>
icon_mapping = map330_icon_table;
break;
default:
- fatal("Magproto: Unknown receiver type.\n");
+ fatal(MYNAME ": Unknown receiver type.\n");
}
}
if (!gr) {
if (!got_version) {
- fatal("Magproto: No data received from GPS.\n");
+ fatal(MYNAME ": No data received from GPS.\n");
} else {
if (is_file) {
found_done = 1;
fprintf(stderr, "RXERR %02x/%02x: '%s'\n", isum, mag_pchecksum(&ibuf[1],isz-5), ibuf);
/* Special case receive errors early on. */
if (!got_version) {
- fatal("Magproto: bad communication. Check bit rate.\n");
+ fatal(MYNAME ": bad communication. Check bit rate.\n");
}
}
if (debug_serial) {
OPEN_EXISTING, 0, NULL);
if (comport == INVALID_HANDLE_VALUE) {
- fatal("Cannot open '%s'", portname);
+ fatal(MYNAME ": '%s'", portname);
}
tio.DCBlength = sizeof(DCB);
GetCommState (comport, &tio);
if (!SetCommState (comport, &tio)) {
CloseHandle(comport);
- fatal("Unable to set port settings");
+ fatal(MYNAME ": set port settings");
}
GetCommTimeouts (comport, &timeout);
timeout.WriteTotalTimeoutConstant = 1000;
if (!SetCommTimeouts (comport, &timeout)) {
CloseHandle (comport);
- fatal("Unable to set timeouts");
+ fatal(MYNAME ": set timeouts");
}
}
WriteFile (comport, obuf, size, &len, NULL);
if (len != size) {
- fatal("Write error. Wrote %d of %d bytes.", len, size);
+ fatal(MYNAME ":. Wrote %d of %d bytes.", len, size);
}
}
magfile_in = fopen(portname, "rb");
if (magfile_in == NULL) {
- fatal("Magproto: Cannot open %s.%s\n",
+ fatal(MYNAME ": Cannot open %s.%s\n",
portname, strerror(errno));
}
while (!got_version) {
mag_readmsg();
if (time(NULL) > later) {
- fatal("Magproto: No acknowledgment from GPS on %s\n",
+ fatal(MYNAME ": No acknowledgment from GPS on %s\n",
portname);
}
}
waypt = calloc(sizeof *waypt, 1);
if (waypt == NULL)
- fatal("Magproto: Cannot allocate memory\n");
+ fatal(MYNAME ": Cannot allocate memory\n");
sscanf(trkmsg,"$PMGNWPL,%lf,%c,%lf,%c,%d,%c,%[^,],%[^,]",
&latdeg,&latdir,
static FILE *mapsource_file_in;
static FILE *mapsource_file_out;
+#define MYNAME "MAPSOURCE"
+
static void
mapsource_rd_init(const char *fname)
{
mapsource_file_in = fopen(fname, "r");
if (mapsource_file_in == NULL) {
- fatal("Cannot open '%s' for reading\n", fname);
+ fatal(MYNAME ": '%s' for reading\n", fname);
}
}
{
mapsource_file_out = fopen(fname, "w");
if (mapsource_file_out == NULL) {
- fatal("Cannot open '%s' for writing\n", fname);
+ fatal(MYNAME ": '%s' for writing\n", fname);
exit(1);
}
}
static FILE *file_in;
static FILE *file_out;
+#define MYNAME "PCX"
+
+
static void
rd_init(const char *fname)
{
file_in = fopen(fname, "r");
if (file_in == NULL) {
- fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+ fatal(MYNAME ": Cannot open %s for reading\n", fname);
}
}
{
file_out = fopen(fname, "w");
if (file_out == NULL) {
- fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+ fatal(MYNAME ": Cannot open %s for writing\n", fname);
}
}
#include <ctype.h>
#include <math.h> /* for M_PI */
+#define MYNAME "PSP"
+
/*#define _DEBUG_PSP 1*/
#define MAXPSPSTRINGSIZE 256
#define MAXPSPOUTPUTPINS 8192 /* Any more points than this is ludicrous */
{
psp_file_in = fopen(fname, "r");
if (psp_file_in == NULL) {
- fatal("PSP: Cannot open %s for reading\n", fname);
+ fatal(MYNAME ": Cannot open %s for reading\n", fname);
}
}
{
psp_file_out = fopen(fname, "w");
if (psp_file_out == NULL) {
- fatal("PSP: Cannot open %s for writing\n", fname);
+ fatal(MYNAME ": Cannot open %s for writing\n", fname);
}
}
wpt_tmp = calloc(sizeof(*wpt_tmp),1);
if (wpt_tmp == NULL) {
- fatal("PSP: cannot allocate memory\n");
+ fatal(MYNAME ": cannot allocate memory\n");
}
/* things we will probably never know about this waypoint */
stringsize *= 2;
if (stringsize > MAXPSPSTRINGSIZE) {
- fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
+ fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
}
/* stringsize bytes - string data */
stringsize *= 2;
if (stringsize > MAXPSPSTRINGSIZE) {
- fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
+ fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
}
#ifdef _DEBUG_PSP
stringsize *= 2;
if (stringsize > MAXPSPSTRINGSIZE) {
- fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
+ fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
}
s = waypt_count();
if (s > MAXPSPOUTPUTPINS) {
- fatal("attempt to output too many pushpins (%d). The max is %d. Sorry.\n", s, MAXPSPOUTPUTPINS);
+ fatal(MYNAME ": output too many pushpins (%d). The max is %d. Sorry.\n", s, MAXPSPOUTPUTPINS);
}
/* insert waypoint count into header */
static FILE *file_in;
static FILE *file_out;
+#define MYNAME "GPSUTIL"
+
static void
rd_init(const char *fname)
{
file_in = fopen(fname, "r");
if (file_in == NULL) {
- fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+ fatal(MYNAME ": Cannot open %s for reading\n", fname);
}
}
{
file_out = fopen(fname, "w");
if (file_out == NULL) {
- fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+ fatal(MYNAME ": Cannot open %s for writing\n", fname);
}
}
&alt, &alttype, desc, icon) > 0) {
wpt_tmp = calloc(sizeof(*wpt_tmp),1);
if (wpt_tmp == NULL) {
- fatal("GPSMAN: cannot allocate memory\n");
+ fatal(MYNAME ": cannot allocate memory\n");
}
wpt_tmp->position.altitude.altitude_meters = alt;
wpt_tmp->shortname = strdup(name);